var data = require("./data.js");

var define = data.define;

var last_x = -1;
var last_y = -1;

function setCursor(x, y, map, mapW, mapH, width, mapMouse) {
  if (x > mapH || y > mapW)
    return;
  if (last_x != -1 && map[last_x][last_y] == define.InputPoint)
    map[last_x][last_y] = 0;

  if ((!data.isWall(map[x][y]) && map[x][y] != define.Block))
    map[x][y] = define.InputPoint;

  last_x = x;
  last_y = y;
  console.log(last_x, last_y)
}

function getX() {
  return last_x;
}

function getY() {
  return last_y;
}

function canInput(map, mapW, mapH, width, mapMouse) {
  return map[last_x][last_y] != define.Wall && map[last_x][last_y] != define.Block;
}

function clear() {
  last_x = -1;
  last_y = -1;
}

function getInfo()
{
  var temp={};
  temp.x=last_x;
  temp.y=last_y;
  temp.url = "";
  temp.flag = 1;
  return temp;
}
module.exports = {
  setCursor: setCursor,
  canInput: canInput,
  getY: getY,
  getX: getX,
  clear: clear,
  getInfo: getInfo
}